package core.ws;

import core.oauth.ServiceFactory;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

/**
 *
 * @author Admin
 */
public class StorageList {

    private Map<String, Storage> map = new HashMap<String, Storage>();

    public StorageList() {
        add(ServiceFactory.DROPBOX, "Dropbox");
        add(ServiceFactory.DRIVE, "Google drive");
        add(ServiceFactory.ONEDRIVE, "One drive");
    }

    private void add(String type, String name) {
        map.put(type,
                new Storage(
                        type,
                        name,
                        ServiceFactory.create(type).getAuthorizationUrl(null)));
    }

    public Collection<Storage> getList() {
        return map.values();
    }

    public Storage get(String type) {
        return map.get(type);
    }

    public void setAuthenticated(String type, boolean value) {
        map.get(type).setIsAuthenticated(value);
    }
}
